<?php
class Validate_EqualInputs extends Zend_Validate_Abstract
{
// Error label; @var const
const INVALID = 'passwordInvalid';

// Error text; @var array
protected $_messageTemplates = array(
    self::INVALID => 'Passwords should be equal.',
);

// Check if two password fields contain the same value; @param string $value is valided
protected $_contextKey;

// @param string. $key is the name of the field $value is compared with
public function __construct($key) {
    $this->_contextKey = $key;
}

// Comparison of the $value with $context[ $this->_contextKey ]; @param string $value is valided
public function isValid($value, $context = null) {

    $value = (string)$value;
    if (is_array($context)) {
        if (isset($context[$this->_contextKey]) && ($value === $context[$this->_contextKey])) {
            return true;
        }
    } else if (is_string($context) && ($value === $context)) {
        return true;
    }
    $this->_error(self::INVALID);
    return false;
    }

}